package main

//
//
//import (
//	"fmt"
//	"time"
//)
//
//// BlockReplenishmentPlan 按3小时区间的补水计划
//type BlockReplenishmentPlan struct {
//	// 区间信息（固定3小时块）
//	BlockStartTime time.Time // 区间开始时间（如 00:00, 03:00, 06:00）
//	BlockEndTime   time.Time // 区间结束时间（如 03:00, 06:00, 09:00）
//
//	// 补水任务信息
//	RefillStartTime time.Time // 补水开始时间（在区间内，如果没有补水则等于BlockStartTime）
//	RefillEndTime   time.Time // 补水结束时间（在区间内，如果没有补水则等于BlockStartTime）
//	RefillAmountM3  float64   // 补水量 (m³)
//	Reason          string    // 补水原因
//	Priority        string    // 优先级 (HIGH/NORMAL/LOW/NONE)
//
//	// 补充信息（用于追踪，可选）
//	HasRefill        bool    // 本区间是否有补水任务
//	BlockIndex       int     // 块索引 (0-7)
//	StartLevelM3     float64 // 区间开始时的水位
//	EndLevelM3       float64 // 区间结束时的水位
//	PredictedUsageM3 float64 // 预测用水量
//}
//
//// SerializableBlockPlan 可序列化的区间补水计划（用于JSON存储）
//type SerializableBlockPlan struct {
//	BlockStartTime   string  `json:"block_start_time"`  // ISO8601格式
//	BlockEndTime     string  `json:"block_end_time"`    // ISO8601格式
//	RefillStartTime  string  `json:"refill_start_time"` // ISO8601格式
//	RefillEndTime    string  `json:"refill_end_time"`   // ISO8601格式
//	RefillAmountM3   float64 `json:"refill_amount_m3"`
//	Reason           string  `json:"reason"`
//	Priority         string  `json:"priority"`
//	HasRefill        bool    `json:"has_refill"`
//	BlockIndex       int     `json:"block_index"`
//	StartLevelM3     float64 `json:"start_level_m3"`
//	EndLevelM3       float64 `json:"end_level_m3"`
//	PredictedUsageM3 float64 `json:"predicted_usage_m3"`
//}
//
//// RunSimulationWithPersistence 运行模拟并返回按3小时区间组织的补水计划
//// 返回值：每个3小时块的补水计划列表 + 最终水位
//func (dp *DailyPlanner) RunSimulationWithPersistence() ([]*BlockReplenishmentPlan, float64) {
//	logTitle(LogLevelInfo, fmt.Sprintf("DAILY PLAN SIMULATION: %s -> 24:00", dp.startTime.Format(TimeLayout)))
//
//	// 计算规划周期（包含部分块和完整块）
//	planningPeriods := calculatePlanningPeriods(dp.startTime, dp.endTime, PlanningHorizon)
//
//	if len(planningPeriods) == 0 {
//		logMessage(LogLevelInfo, "No planning periods needed (already at or past 24:00)\n")
//		return nil, dp.initialLevel
//	}
//
//	logMessage(LogLevelInfo, "Start time: %s\n", dp.startTime.Format(TimeLayout))
//	if len(planningPeriods) > 0 {
//		if planningPeriods[0].IsPartial {
//			logMessage(LogLevelDebug, "First period: %s -> %s (PARTIAL BLOCK, %.1f%% of full block)\n",
//				planningPeriods[0].Start.Format(HourLayout),
//				planningPeriods[0].End.Format(HourLayout),
//				multiply(planningPeriods[0].UsageFraction, 100))
//			logMessage(LogLevelDebug, "  Block time range: %s -> %s\n",
//				planningPeriods[0].BlockStart.Format(HourLayout),
//				planningPeriods[0].End.Format(HourLayout))
//		} else {
//			logMessage(LogLevelDebug, "First period: %s -> %s (FULL BLOCK)\n",
//				planningPeriods[0].Start.Format(HourLayout),
//				planningPeriods[0].End.Format(HourLayout))
//		}
//	}
//	logMessage(LogLevelInfo, "Total planning periods: %d\n", len(planningPeriods))
//	logSubTitle(LogLevelInfo)
//
//	var blockPlans []*BlockReplenishmentPlan
//	simulatedLevel := dp.initialLevel
//
//	for i, period := range planningPeriods {
//		// 准备调整后的预测数据
//		adjustedPrediction3h := make([]float64, len(dp.fullDayPrediction3h)-period.BlockIndex)
//
//		if period.BlockIndex < len(dp.fullDayPrediction3h) {
//			copy(adjustedPrediction3h, dp.fullDayPrediction3h[period.BlockIndex:])
//
//			if period.IsPartial && len(adjustedPrediction3h) > 0 {
//				originalBlockUsage := dp.fullDayPrediction3h[period.BlockIndex]
//				adjustedPrediction3h[0] = multiply(originalBlockUsage, period.UsageFraction)
//
//				logMessage(LogLevelDebug, "  [Adjustment] Block %d (%s-%s): Full usage=%.2f m³, Remaining %.1f%% (%.2f m³)\n",
//					period.BlockIndex,
//					period.BlockStart.Format(HourLayout),
//					period.End.Format(HourLayout),
//					originalBlockUsage,
//					multiply(period.UsageFraction, 100),
//					adjustedPrediction3h[0])
//			}
//		} else {
//			lastValue := 2.0
//			if len(dp.fullDayPrediction3h) > 0 {
//				lastValue = dp.fullDayPrediction3h[len(dp.fullDayPrediction3h)-1]
//			}
//			if period.IsPartial {
//				lastValue = multiply(lastValue, period.UsageFraction)
//			}
//			adjustedPrediction3h = []float64{lastValue, lastValue, lastValue}
//		}
//
//		// 构建系统状态
//		currentState := SystemState{
//			CurrentTime:         period.Start,
//			CurrentLevelM3:      simulatedLevel,
//			Prediction3h:        adjustedPrediction3h,
//			Prediction30min:     dp.fullDayPrediction30min,
//			NextDayPrediction3h: dp.nextDayPrediction3h,
//			BlockStartTime:      period.BlockStart,
//		}
//
//		// 判断是否是最后一个周期（21:00-24:00）
//		isLastPeriod := period.BlockIndex == 7
//
//		// 【保持原有逻辑】生成补水任务
//		var task *ReplenishmentTask
//		if isLastPeriod {
//			task = dp.planner.GenerateLastPlan(currentState)
//		} else {
//			task = dp.planner.GeneratePlan(currentState)
//		}
//
//		// 计算本周期的实际用水量（用于模拟）
//		var usageInPeriod float64
//		if period.BlockIndex < len(dp.fullDayPrediction3h) {
//			baseUsage := dp.fullDayPrediction3h[period.BlockIndex]
//			usageInPeriod = multiply(baseUsage, period.UsageFraction)
//		} else {
//			if len(dp.fullDayPrediction3h) > 0 {
//				baseUsage := dp.fullDayPrediction3h[len(dp.fullDayPrediction3h)-1]
//				usageInPeriod = multiply(baseUsage, period.UsageFraction)
//			} else {
//				usageInPeriod = multiply(2.0, period.UsageFraction)
//			}
//		}
//
//		// 【新增】创建区间补水计划
//		blockPlan := &BlockReplenishmentPlan{
//			BlockStartTime:   period.BlockStart,
//			BlockEndTime:     period.End,
//			BlockIndex:       period.BlockIndex,
//			StartLevelM3:     simulatedLevel,
//			PredictedUsageM3: usageInPeriod,
//		}
//
//		// 填充补水任务信息
//		refillInPeriod := 0.0
//		if task != nil {
//			blockPlan.HasRefill = true
//			blockPlan.RefillStartTime = task.StartTime
//			blockPlan.RefillEndTime = task.EndTime
//			blockPlan.RefillAmountM3 = task.AmountM3
//			blockPlan.Reason = task.Reason
//			blockPlan.Priority = task.Priority
//			refillInPeriod = task.AmountM3
//
//			logMessage(LogLevelInfo, "=> Generated Task: [%s] Replenish %.2f m³ from %s to %s (%s)\n",
//				task.Priority, task.AmountM3,
//				task.StartTime.Format(HourLayout), task.EndTime.Format(HourLayout),
//				task.Reason)
//		} else {
//			blockPlan.HasRefill = false
//			blockPlan.RefillStartTime = period.BlockStart
//			blockPlan.RefillEndTime = period.BlockStart
//			blockPlan.RefillAmountM3 = 0
//			blockPlan.Reason = "无需补水"
//			blockPlan.Priority = "NONE"
//
//			logMessage(LogLevelDebug, "=> No task generated for this period.\n")
//		}
//
//		// 更新模拟液位
//		nextSimulatedLevel := round2(simulatedLevel - usageInPeriod + refillInPeriod)
//
//		// 物理限制
//		if nextSimulatedLevel > MaxSafeLevelM3 {
//			nextSimulatedLevel = MaxSafeLevelM3
//		}
//		if nextSimulatedLevel < 0 {
//			nextSimulatedLevel = 0
//		}
//
//		blockPlan.EndLevelM3 = nextSimulatedLevel
//
//		blockType := "FULL"
//		if period.IsPartial {
//			blockType = fmt.Sprintf("PARTIAL(%.0f%%)", multiply(period.UsageFraction, 100))
//		}
//
//		logMessage(LogLevelInfo, "Period %d [%s -> %s] %s: StartLevel=%.2f, Usage=%.2f, Refill=%.2f, EndLevel=%.2f\n",
//			i+1,
//			period.Start.Format(HourLayout),
//			period.End.Format(HourLayout),
//			blockType,
//			simulatedLevel,
//			usageInPeriod,
//			refillInPeriod,
//			nextSimulatedLevel,
//		)
//		logSubTitle(LogLevelInfo)
//
//		blockPlans = append(blockPlans, blockPlan)
//		simulatedLevel = nextSimulatedLevel
//	}
//
//	logTitle(LogLevelInfo, fmt.Sprintf("SIMULATION COMPLETE - Final Level: %.2f m³", simulatedLevel))
//
//	return blockPlans, simulatedLevel
//}
//
//// PrintBlockPlans 打印所有块的补水计划（格式化输出）
//func PrintBlockPlans(plans []*BlockReplenishmentPlan) {
//	logTitle(LogLevelInfo, "BLOCK-BASED REPLENISHMENT PLANS")
//
//	totalRefill := 0.0
//	refillCount := 0
//
//	for i, plan := range plans {
//		logMessage(LogLevelInfo, "\n%d. 区间 [%s - %s] (块索引: %d)\n",
//			i+1,
//			plan.BlockStartTime.Format(HourLayout),
//			plan.BlockEndTime.Format(HourLayout),
//			plan.BlockIndex)
//
//		logMessage(LogLevelInfo, "   水位变化: %.2f m³ → %.2f m³\n",
//			plan.StartLevelM3, plan.EndLevelM3)
//		logMessage(LogLevelInfo, "   预测用水量: %.2f m³\n", plan.PredictedUsageM3)
//
//		if plan.HasRefill {
//			logMessage(LogLevelInfo, "   ✓ 补水任务:\n")
//			logMessage(LogLevelInfo, "     - 补水时间:  %s → %s\n",
//				plan.RefillStartTime.Format(HourLayout),
//				plan.RefillEndTime.Format(HourLayout))
//			logMessage(LogLevelInfo, "     - 补水量:    %.2f m³\n", plan.RefillAmountM3)
//			logMessage(LogLevelInfo, "     - 优先级:    %s\n", plan.Priority)
//			logMessage(LogLevelInfo, "     - 原因:      %s\n", plan.Reason)
//
//			totalRefill += plan.RefillAmountM3
//			refillCount++
//		} else {
//			logMessage(LogLevelInfo, "   ○ 无需补水\n")
//		}
//	}
//
//	logSeparator(LogLevelInfo, "=", 60)
//	logMessage(LogLevelInfo, "总结:\n")
//	logMessage(LogLevelInfo, "  总区间数:           %d\n", len(plans))
//	logMessage(LogLevelInfo, "  有补水任务的区间:   %d\n", refillCount)
//	logMessage(LogLevelInfo, "  总补水量:           %.2f m³\n", totalRefill)
//	if len(plans) > 0 {
//		logMessage(LogLevelInfo, "  最终水位:           %.2f m³\n", plans[len(plans)-1].EndLevelM3)
//	}
//	logSeparator(LogLevelInfo, "=", 60)
//}
//
//// ConvertToSerializableBlockPlans 转换为可序列化格式（用于JSON存储）
//func ConvertToSerializableBlockPlans(plans []*BlockReplenishmentPlan) []SerializableBlockPlan {
//	result := make([]SerializableBlockPlan, len(plans))
//
//	for i, plan := range plans {
//		result[i] = SerializableBlockPlan{
//			BlockStartTime:   plan.BlockStartTime.Format(time.RFC3339),
//			BlockEndTime:     plan.BlockEndTime.Format(time.RFC3339),
//			RefillStartTime:  plan.RefillStartTime.Format(time.RFC3339),
//			RefillEndTime:    plan.RefillEndTime.Format(time.RFC3339),
//			RefillAmountM3:   plan.RefillAmountM3,
//			Reason:           plan.Reason,
//			Priority:         plan.Priority,
//			HasRefill:        plan.HasRefill,
//			BlockIndex:       plan.BlockIndex,
//			StartLevelM3:     plan.StartLevelM3,
//			EndLevelM3:       plan.EndLevelM3,
//			PredictedUsageM3: plan.PredictedUsageM3,
//		}
//	}
//
//	return result
//}
//
//func main() {
//	// 设置日志级别
//	currentLogLevel = LogLevelInfo
//
//	// 初始化JSON存储（可配置存储路径）
//	storageDir := "./water_plans" // 可以改为绝对路径
//	storage, err := NewJSONStorage(storageDir)
//	if err != nil {
//		logMessage(LogLevelError, "Failed to initialize storage: %v\n", err)
//		return
//	}
//	logMessage(LogLevelInfo, "✓ Storage initialized at: %s\n\n", storageDir)
//
//	// 设置用户规则
//	today := time.Now()
//	loc := today.Location()
//
//	parseTime := func(hourMinute string) time.Time {
//		t, _ := time.ParseInLocation(HourLayout, hourMinute, loc)
//		return time.Date(today.Year(), today.Month(), today.Day(), t.Hour(), t.Minute(), 0, 0, loc)
//	}
//
//	rules := UserRules{
//		PriorityPeriods: []TargetedTimeRange{
//			{TimeRange: TimeRange{Start: parseTime("03:00"), End: parseTime("06:00")}, TargetLevelM3: 12.0},
//			{TimeRange: TimeRange{Start: parseTime("12:00"), End: parseTime("14:00")}, TargetLevelM3: 10.0},
//		},
//		PeakPeriods: []TargetedTimeRange{
//			{TimeRange: TimeRange{Start: parseTime("06:00"), End: parseTime("09:00")}, TargetLevelM3: 12.0},
//			{TimeRange: TimeRange{Start: parseTime("18:00"), End: parseTime("24:00")}, TargetLevelM3: 12.0},
//		},
//		ForbiddenPeriods: []TimeRange{
//			{Start: parseTime("09:00"), End: parseTime("12:00")},
//			{Start: parseTime("14:00"), End: parseTime("16:00")},
//		},
//	}
//
//	// 准备预测数据
//	mockPrediction3h := []float64{2, 4, 8, 6, 4, 4, 6, 4}
//	mockPrediction30min := []float64{
//		0.2, 0.3, 0.5, 0.5, 0.5, 0.0, // 00:00 - 03:00
//		0.2, 0.3, 0.5, 0.5, 0.5, 0.0, // 03:00 - 06:00
//		0.5, 0.5, 0.5, 1.0, 1.0, 0.5, // 06:00 - 09:00
//		1.5, 1.5, 1.5, 1.5, 1.0, 1.0, // 09:00 - 12:00
//	}
//	mockNextDayPrediction3h := []float64{2.0, 2.0}
//
//	// 运行模拟
//	logMessage(LogLevelInfo, "\n\n")
//	logTitle(LogLevelInfo, "测试案例: 从 00:00 开始")
//	logMessage(LogLevelInfo, "\n")
//
//	startTime := parseTime("00:00")
//	initialLevel := 8.0
//	dp := NewDailyPlanner(rules, startTime, initialLevel, mockPrediction3h, mockPrediction30min, mockNextDayPrediction3h)
//
//	// 运行模拟并获取结果
//	tasks, finalLevel := dp.RunSimulationWithPersistence()
//
//	// 创建PlanResult对象
//	planResult := NewPlanResult(dp, tasks, finalLevel)
//
//	// 保存到JSON文件
//	if err := storage.Save(planResult); err != nil {
//		logMessage(LogLevelError, "Failed to save plan: %v\n", err)
//		return
//	}
//
//	// 打印摘要
//	logMessage(LogLevelInfo, "\n")
//	PrintPlanSummary(planResult)
//
//	// 演示如何加载数据
//	logMessage(LogLevelInfo, "\n")
//	logTitle(LogLevelInfo, "STORAGE OPERATIONS DEMO")
//
//	//// 1. 按ID加载
//	//logMessage(LogLevelInfo, "\n1. Loading plan by ID...\n")
//	//loadedPlan, err := storage.Load(planResult.ID)
//	//if err != nil {
//	//	logMessage(LogLevelError, "Failed to load plan: %v\n", err)
//	//} else {
//	//	logMessage(LogLevelInfo, "✓ Loaded plan: %s (Date: %s, Tasks: %d)\n",
//	//		loadedPlan.ID, loadedPlan.PlanDate, loadedPlan.TaskCount)
//	//}
//	//
//	//// 2. 按日期加载
//	//logMessage(LogLevelInfo, "\n2. Loading plans by date...\n")
//	//dateStr := today.Format("2006-01-02")
//	//plansByDate, err := storage.LoadByDate(dateStr)
//	//if err != nil {
//	//	logMessage(LogLevelError, "Failed to load plans by date: %v\n", err)
//	//} else {
//	//	logMessage(LogLevelInfo, "✓ Found %d plan(s) for date %s\n", len(plansByDate), dateStr)
//	//	for i, p := range plansByDate {
//	//		logMessage(LogLevelInfo, "  %d. ID=%s, Tasks=%d, TotalRefill=%.2f m³\n",
//	//			i+1, p.ID[:8]+"...", p.TaskCount, p.TotalRefillM3)
//	//	}
//	//}
//	//
//	//// 3. 列出最近的计划
//	//logMessage(LogLevelInfo, "\n3. Listing recent plans...\n")
//	//recentPlans, err := storage.List(0, 5)
//	//if err != nil {
//	//	logMessage(LogLevelError, "Failed to list plans: %v\n", err)
//	//} else {
//	//	logMessage(LogLevelInfo, "✓ Found %d recent plan(s)\n", len(recentPlans))
//	//	for i, p := range recentPlans {
//	//		logMessage(LogLevelInfo, "  %d. Date=%s, Time=%s, Tasks=%d\n",
//	//			i+1, p.PlanDate, parseTime(p.CreatedAt).Format("15:04:05"), p.TaskCount)
//	//	}
//	//}
//	//
//	//// 4. 获取最新计划
//	//logMessage(LogLevelInfo, "\n4. Getting latest plan...\n")
//	//latestPlan, err := storage.GetLatest()
//	//if err != nil {
//	//	logMessage(LogLevelError, "Failed to get latest plan: %v\n", err)
//	//} else {
//	//	logMessage(LogLevelInfo, "✓ Latest plan: Date=%s, Created=%s\n",
//	//		latestPlan.PlanDate, parseTime(latestPlan.CreatedAt).Format(TimeLayout))
//	//}
//	//
//	//logSeparator(LogLevelInfo, "=", 60)
//	//logMessage(LogLevelInfo, "\n✓ All operations completed successfully!\n")
//}
//
////func main() {
////	// 设置日志级别
////	currentLogLevel = LogLevelInfo
////
////	// === 1. 系统配置 ===
////	today := time.Now()
////	loc := today.Location()
////	dateStr := today.Format("2006-01-02")
////
////	parseTime := func(hourMinute string) time.Time {
////		t, _ := time.ParseInLocation(HourLayout, hourMinute, loc)
////		return time.Date(today.Year(), today.Month(), today.Day(), t.Hour(), t.Minute(), 0, 0, loc)
////	}
////
////	// 用户规则
////	rules := UserRules{
////		PriorityPeriods: []TargetedTimeRange{
////			{TimeRange: TimeRange{Start: parseTime("03:00"), End: parseTime("06:00")}, TargetLevelM3: 12.0},
////			{TimeRange: TimeRange{Start: parseTime("12:00"), End: parseTime("14:00")}, TargetLevelM3: 10.0},
////		},
////		PeakPeriods: []TargetedTimeRange{
////			{TimeRange: TimeRange{Start: parseTime("06:00"), End: parseTime("09:00")}, TargetLevelM3: 12.0},
////			{TimeRange: TimeRange{Start: parseTime("18:00"), End: parseTime("24:00")}, TargetLevelM3: 12.0},
////		},
////		ForbiddenPeriods: []TimeRange{
////			{Start: parseTime("09:00"), End: parseTime("12:00")},
////			{Start: parseTime("14:00"), End: parseTime("16:00")},
////		},
////	}
////
////	// 初始预测数据
////	prediction3h := []float64{2, 4, 8, 6, 4, 4, 6, 4}
////	nextDayPrediction3h := []float64{2.0, 2.0}
////
////	prediction30min := generatePrediction30min()
////
////	// === 2. 创建整合系统 ===
////	logTitle(LogLevelInfo, "步骤1: 创建整合系统")
////
////	system, err := NewIntegratedSystem("./predictions", "./plans", rules)
////	if err != nil {
////		fmt.Printf("创建系统失败: %v\n", err)
////		return
////	}
////
////	logMessage(LogLevelInfo, "✅ 整合系统创建成功\n\n")
////
////	// === 3. 初始化系统 ===
////	logTitle(LogLevelInfo, "步骤2: 初始化系统")
////
////	startTime := parseTime("00:00")
////	initialLevel := 8.0
////
////	if err := system.Initialize(
////		dateStr,
////		startTime,
////		initialLevel,
////		prediction30min,
////		prediction3h,
////		nextDayPrediction3h,
////	); err != nil {
////		fmt.Printf("初始化失败: %v\n", err)
////		return
////	}
////
////	// 打印初始预测曲线
////	PrintPredictionCurve(system.GetCurrentPrediction())
////
////	// === 4. 模拟一天的运行 ===
////	logTitle(LogLevelInfo, "步骤3: 模拟一天的运行（每30分钟监测）")
////
////	// 定义模拟场景
////	scenarios := []struct {
////		time        string
////		actualUsage float64
////		level       float64
////		description string
////	}{
////		{"00:30", 0.25, 7.75, "用水量增加（偶发波动）"},
////		{"01:00", 0.30, 7.45, "正常用水"},
////		{"01:30", 0.28, 7.17, "用水量增加（偶发波动）"},
////		{"02:00", 0.50, 6.67, "异常事件"},
////		{"02:30", 0.30, 6.37, "恢复正常"},
////		{"03:00", 0.35, 6.02, "正常用水"},
////		//{"03:30", 0.70, 5.32, "用水量大幅增加（趋势变化开始）"},
////		//{"04:00", 0.75, 4.57, "持续高用水量（趋势变化）"},
////		//{"04:30", 0.80, 3.77, "持续高用水量（触发重新规划）"},
////	}
////
////	decisionHistory := make([]*UpdateDecision, 0)
////
////	for i, scenario := range scenarios {
////		currentTime := parseTime(scenario.time)
////
////		logMessage(LogLevelInfo, "\n")
////		logTitle(LogLevelInfo, fmt.Sprintf("监测点 %d/%d - %s", i+1, len(scenarios), scenario.time))
////		logMessage(LogLevelInfo, "场景描述: %s\n", scenario.description)
////		logSeparator(LogLevelInfo, "=", 60)
////
////		decision, err := system.MonitorAndAdjust(
////			scenario.actualUsage,
////			currentTime,
////			scenario.level,
////		)
////
////		if err != nil {
////			fmt.Printf("监测调整失败: %v\n", err)
////			continue
////		}
////
////		decisionHistory = append(decisionHistory, decision)
////
////		// 如果发生了重大更新，打印当前状态
////		if decision.ShouldReplan {
////			system.PrintSystemStatus()
////		}
////
////		// 暂停以便查看输出
////		time.Sleep(100 * time.Millisecond)
////	}
////
////	// === 5. 打印监测历史摘要 ===
////	logTitle(LogLevelInfo, "步骤4: 监测历史摘要")
////
////	printDecisionSummary(decisionHistory, scenarios)
////
////	// === 6. 打印偏差历史 ===
////	logMessage(LogLevelInfo, "\n")
////	system.deviationAnalyzer.PrintDeviationHistory()
////
////	// === 7. 打印最终状态 ===
////	logMessage(LogLevelInfo, "\n")
////	system.PrintSystemStatus()
////
////	// === 8. 打印最终预测曲线 ===
////	logMessage(LogLevelInfo, "\n")
////	PrintPredictionCurve(system.GetCurrentPrediction())
////
////	// === 9. 总结 ===
////	logTitle(LogLevelInfo, "系统运行总结")
////
////	logMessage(LogLevelInfo, "✅ 完成 %d 次监测\n", len(scenarios))
////	logMessage(LogLevelInfo, "✅ 预测曲线版本: v1 → v%d\n", system.GetCurrentPrediction().Version)
////
////	// 统计更新决策
////	updateCount := 0
////	replanCount := 0
////	for _, decision := range decisionHistory {
////		if decision.ShouldUpdate30min || decision.ShouldReaggregate3h {
////			updateCount++
////		}
////		if decision.ShouldReplan {
////			replanCount++
////		}
////	}
////
////	logMessage(LogLevelInfo, "✅ 预测曲线更新: %d 次\n", updateCount)
////	logMessage(LogLevelInfo, "✅ 补水计划重规划: %d 次\n", replanCount)
////}
//
//// generatePrediction30min 生成30分钟预测数据（48个值）
//func generatePrediction30min() []float64 {
//	// 简化版：根据3小时预测均分
//	pred3h := []float64{2, 4, 8, 6, 4, 4, 6, 4}
//	pred30min := make([]float64, 48)
//
//	for i := 0; i < 8; i++ {
//		value30min := pred3h[i] / 6.0 // 平均分配到6个30分钟
//		for j := 0; j < 6; j++ {
//			pred30min[i*6+j] = round2(value30min)
//		}
//	}
//
//	return pred30min
//}
//
//// printDecisionSummary 打印决策摘要
//func printDecisionSummary(decisions []*UpdateDecision, scenarios []struct {
//	time        string
//	actualUsage float64
//	level       float64
//	description string
//}) {
//	logMessage(LogLevelInfo, "%-8s %-20s %-15s %-12s %-12s %-12s\n",
//		"时间", "场景", "决策类型", "更新30min", "重聚合3h", "重新规划")
//	logSeparator(LogLevelInfo, "-", 90)
//
//	for i, decision := range decisions {
//		update30 := "❌"
//		if decision.ShouldUpdate30min {
//			update30 = "✅"
//		}
//
//		reagg3h := "❌"
//		if decision.ShouldReaggregate3h {
//			reagg3h = "✅"
//		}
//
//		replan := "❌"
//		if decision.ShouldReplan {
//			replan = "✅"
//		}
//
//		logMessage(LogLevelInfo, "%-8s %-20s %-15s %-12s %-12s %-12s\n",
//			scenarios[i].time,
//			scenarios[i].description,
//			decision.Scenario.String(),
//			update30,
//			reagg3h,
//			replan)
//	}
//
//	logSeparator(LogLevelInfo, "=", 90)
//}
